package com.ellricky.excute_president.ui.activity.school

import android.view.View
import android.widget.AdapterView
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.andr.common.widget.refresh.RefreshFlag
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.excute_president.API_TODAY_COMPLAIN
import com.ellricky.excute_president.ComplainRecordEntity
import com.ellricky.excute_president.R
import com.ellricky.baselib.ui.order.complain.ComplainDetailActivity

class ComplainRecordActivity : BaseRefreshActivity<Void, BasePresenter<Void>, ComplainRecordEntity>() {


    override fun initUIView() {
        super.initUIView()
        mTvTitle.setText(R.string.pd_today_complain)
    }


    override fun getRvAdapter(): BaseRecyclerAdapter<ComplainRecordEntity>? {
        return null
    }

    override fun getResponseCallback(): BaseCallback {
        return object : EListCallback<ComplainRecordEntity>(this) {
            override fun onSuccess(data: MutableList<ComplainRecordEntity>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(dataSource, refresh)
            }

            override fun onErrorCode(code: String?, msg: String?) {
                super.onErrorCode(code, msg)
                rvView.onRefreshFailed(refresh)
            }

            override fun onHttpError(code: String?, msg: String?) {
                super.onHttpError(code, msg)
                rvView.onRefreshFailed(refresh)
            }
        }
    }

    override fun getUrlPath(): String {
        return API_TODAY_COMPLAIN
    }

    override fun onItemClick(adapterView: AdapterView<*>?, view: View?, i: Int, l: Long) {
        super.onItemClick(adapterView, view, i, l)

        EAppUtil.jumpPageWithId(
                this, ComplainDetailActivity::class.java, adapter[i].id
        )
    }

    override fun initParamMap() {

    }

    override fun setRefreshListener() {
        rvView.init(this, RefreshFlag.NONE)
    }

}
